home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Ready to go... Start slave task and wait for it to finish. *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1991, 1992 by H. Roy Engehausen. All *)
- (* rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- PROCEDURE do_this_path_part_2(path_common : path_block_ptr);
-
- VAR
- fwd_port : port_block_ptr;
- i : BYTE;
- look_port : port_block_ptr;
- look_tcb : tcb_ptr;
- loop_port : port_block_ptr;
- sav_port : port_block_ptr;
- this_chan : BYTE;
-
- (*=========================================================================*)
- (* Function to test if it is a BBS *)
- (*=========================================================================*)
-
- FUNCTION test_call_is_bbs : BOOLEAN;
-
- VAR
- uid_i_current : user_index_ptr;
- uid_buffer : user_record_type;
-
- BEGIN;
-
- test_call_is_bbs := FALSE;
-
- uid_i_current := find_uid(path_common^.path_call);
- IF uid_i_current = NIL THEN
- EXIT;
-
- uid_buffer := get_uid(uid_i_current)^;
- IF ((uid_buffer.user_flag AND (user_f_bbs OR user_f_abbs OR user_f_pbbs))
- = 0) THEN
- EXIT;
-
- test_call_is_bbs := TRUE;
-
- END; (*----- End of test it is a BBS ------------------------------------*)
-
- (*=========================================================================*)
- (* Function to write message *)
- (*=========================================================================*)
-
- PROCEDURE tell_user;
-
- VAR
- t : STRING[3];
-
- BEGIN;
-
- WITH path_common^ DO
- BEGIN;
- STR(path_msg_count, t);
- window_write(path_write_p,
- 'Forwarding to ' + path_target + ' with '
- + t + ' outbound message(s).');
- END;
-
- END;
-
- (*=========================================================================*)
- (* Main line *)
- (*=========================================================================*)
-
- BEGIN;
-
- WITH path_common^ DO
- BEGIN;
-
- {$IFDEF DEBUG_PORT}
- trace_data('P2 1', 0, active_port, '');
- {$ENDIF}
-
- (*-------------------------------------------------------------------*)
- (* Tell user what happening *)
- (*-------------------------------------------------------------------*)
-
- tell_user;
-
- (*-------------------------------------------------------------------*)
- (* If no sub task then do it! *)
- (*-------------------------------------------------------------------*)
-
- IF NOT path_common^.path_sub_sw THEN
- BEGIN;
-
- {$IFDEF DEBUG_PORT}
- trace_data('P2 2', 0, active_port, '');
- {$ENDIF}
-
- forward_main(path_common);
- EXIT;
- END;
-
- {$IFDEF DEBUG_PORT}
- trace_data('P2 3', 0, active_port, '');
- {$ENDIF}
-
- (*-------------------------------------------------------------------*)
- (* Make sure we don't have a duplicate connect! *)
- (*-------------------------------------------------------------------*)
-
- IF opt_block.opt_already_conn THEN
- BEGIN;
-
- look_tcb := active_tcb^.next_tcb;
- WHILE look_tcb <> active_tcb DO
- IF (look_tcb^.tcb_type = th_user)
- AND (path_call = look_tcb^.uid_data.user_id) THEN
- BEGIN;
- window_write(path_write_p,
- path_target + '(' + path_call +
- + ') connected on another channel. Skipping');
- EXIT;
- END
- ELSE
- look_tcb := look_tcb^.next_tcb;
-
- END;
-
- (*-------------------------------------------------------------------*)
- (* Make sure we have a bbs target *)
- (*-------------------------------------------------------------------*)
-
- IF NOT test_call_is_bbs THEN
- BEGIN;
-
- window_write(path_write_p,
- path_target + '(' + path_call +
- + ') is not a BBS. Skipping');
- EXIT;
- END;
-
- (*-------------------------------------------------------------------*)
- (* Handle forward to a file *)
- (*-------------------------------------------------------------------*)
-
- IF path_port[1] = 'L' THEN
- BEGIN;
- path_info := COPY(path_info, 2, 255);
- strip_var(path_info, 'B');
- upcase_str_var(path_info);
- export_cmd('E ' + path_info, path_common);
- path_did_all := TRUE;
- EXIT;
- END;
-
- (*-------------------------------------------------------------------*)
- (* Find the port wanted *)
- (*-------------------------------------------------------------------*)
-
- fwd_port := find_port_addr(path_port[1]);
-
- IF fwd_port = NIL THEN
- BEGIN;
- window_write(path_write_p,
- 'Port ' + path_port + ' for ' + path_target
- + ' does not exist!');
- EXIT;
- END;
-
- (*-------------------------------------------------------------------*)
- (* If port is locked then tell him and hang up *)
- (*-------------------------------------------------------------------*)
-
- IF fwd_port^.port_operate_mode.mode_stop_fwd
- OR opt_block.operate_mode.mode_stop_fwd THEN
- BEGIN;
- window_write(path_write_p,
- 'Sysop has locked out forwarding on port '
- + path_port);
- EXIT;
- END;
-
- (*-------------------------------------------------------------------*)
- (* If user requests, make sure TNC is free *)
- (*-------------------------------------------------------------------*)
-
- IF fwd_port^.port_no_busy_fwd THEN
- BEGIN;
-
- FOR i := 1 TO fwd_port^.max_chan DO
- BEGIN;
- look_tcb := fwd_port^.connected^[i];
- IF (i <> this_chan)
- AND (look_tcb <> NIL)
- AND ((fwd_port^.port_type <> port_pcpa)
- OR (look_tcb^.tcb_port = fwd_port)) THEN
- BEGIN;
- window_write(path_write_p,
- 'Port ' + path_port + ' is busy');
- window_write(path_write_p,
- ' User is ' + look_tcb^.port_chan_s
- + ' ' + look_tcb^.tcb_name);
- EXIT;
- END;
- END;
-
- END;
-
- (*-------------------------------------------------------------------*)
- (* Set the channel *)
- (*-------------------------------------------------------------------*)
-
- IF (fwd_port^.port_type <> port_modem)
- AND (fwd_port^.port_type <> port_null_modem) THEN
- BEGIN;
- this_chan := fwd_port^.max_conn;
- IF NOT fwd_port^.port_no_busy_fwd THEN
- INC(this_chan);
- END
- ELSE
- this_chan := 1;
-
- (*-------------------------------------------------------------------*)
- (* Make sure channel is free *)
- (*-------------------------------------------------------------------*)
-
- IF fwd_port^.connected^[this_chan] <> NIL THEN
- BEGIN;
-
- window_write(path_write_p,
- 'Port ' + path_port + ' forward channel is busy');
-
- look_tcb := fwd_port^.connected^[this_chan];
- window_write('FO::', 'User is '
- + look_tcb^.port_chan_s + ' ' + look_tcb^.tcb_name);
-
- EXIT;
- END;
-
- (*-------------------------------------------------------------------*)
- (* Start the new task *)
- (*-------------------------------------------------------------------*)
-
- active_tcb^.channel := this_chan;
-
- active_tcb^.port_chan_s := fwd_port^.port_char
- + byte_to_char[this_chan];
-
- sav_port := active_port;
- active_port := fwd_port;
- active_tcb^.tcb_port := fwd_port;
-
- path_common_temp := path_common;
- fwd_slave_tcb := task_create(@forward_to_remote,
- forwardsub_stack_size);
-
- (*-------------------------------------------------------------------*)
- (* Restore things *)
- (*-------------------------------------------------------------------*)
-
- active_port := sav_port;
- active_tcb^.tcb_port := sav_port;
- active_tcb^.port_chan_s := 'FO';
-
- (*-------------------------------------------------------------------*)
- (* Give error message *)
- (*-------------------------------------------------------------------*)
-
- IF fwd_slave_tcb = NIL THEN
- BEGIN;
- window_write(path_write_p, 'Out of tasks for forward');
- EXIT;
- END;
-
- (*-------------------------------------------------------------------*)
- (* Move the path msg data array to this task *)
- (*-------------------------------------------------------------------*)
-
- move_task_mem(path_block_mem_id, active_tcb, fwd_slave_tcb);
-
- (*-------------------------------------------------------------------*)
- (* Wait for completion of its work *)
- (*-------------------------------------------------------------------*)
-
- wait_for_dead_task(fwd_slave_tcb);
-
- END;
-
- END;